import org.junit.*;
import org.junit.runner.*;
import org.junit.runner.notification.*;
import static org.junit.Assert.*;
import java.util.Arrays;

public class InsertionSort2Test {

    private InsertionSort2<Integer> sorter;

    public static void main(String[] args) {
        Result result = JUnitCore.runClasses(InsertionSort2Test.class);
        for (Failure failure : result.getFailures()) {
            System.out.println(failure.getTestHeader() + ": " + failure.getMessage());
        }
        System.out.println(result.wasSuccessful());
    }

    @Before
    public void setUp() {
        sorter = new InsertionSort2<Integer>();
    }

    @After
    public void tearDown() {
        sorter = null;
    }
    
    @Test
    public void test1() throws Exception {
        Integer[] a = {5, 2, 6, 1, 4, 8, 7, 9, 0, 3};
        Integer[] b = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
        sorter.sort(a, a.length - 1);
        assertEquals("1. Unique queue", Arrays.toString(a), Arrays.toString(b));
    }

    @Test
    public void test2() throws Exception {
        Integer[] a = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
        Integer[] b = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
        sorter.sort(a, a.length - 1);
        assertEquals("2. Repeated queue", Arrays.toString(a), Arrays.toString(b));
    }

    @Test
    public void test3() throws Exception {
        Integer[] a = {1};
        Integer[] b = {1};
        sorter.sort(a, a.length - 1);
        assertEquals("3. Single item array", Arrays.toString(a), Arrays.toString(b));
    }

}

